<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加卡车信息</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
<form id="formSet1">
	<table class="layout2col1">
        <tbody>
            <tr>
            	<td width="80%" valign="top">
            		<div class="sqPanel">
                        <div class="sqPanel_head">
                        	<div class="label">完善产品详细信息</div>
                        </div>
                    </div>
                        <div class="fieldset1 tabel_col clearFix">
                        	<div class="fieldBox col_33">
	                        	<div class="label">产品名称</span></div>
				                <div class="field">
				                	<input name="prdNm" id="prdNm" type="text" class="ui-textbox" readonly>
				                </div>
				            </div>
                        	<div class="fieldBox col_33">
	                        	<div class="label">产品类型</span></div>
				                <div class="field">
				                	<input name="prdTypCdNm" id="prdTypCdNm" type="text" class="ui-textbox" readonly>
				                </div>
				            </div>
                        	<div class="fieldBox col_33">
	                        	<div class="label">产品所属厂商</span></div>
				                <div class="field">
				                	<input name="mfrNm" id="mfrNm" type="text" class="ui-textbox" readonly>
				                </div>
				            </div>
                        	<div class="fieldBox col_33">
	                        	<div class="label">产品品牌</span></div>
				                <div class="field">
				                	<input name="brCdNm" id="brCdNm" type="text" class="ui-textbox" readonly>
				                </div>
				            </div>
                        	<div class="fieldBox col_33">
	                        	<div class="label">设备状态 (是否启用)</span></div>
				                <div class="field">
				                	<input name="isValidNm" id="isValidNm" type="text" class="ui-textbox" readonly>
				                </div>
				            </div>
				            <div class="fieldBox col_33">
				            	<div class="label">产品型号</div>
				                <div class="field">
				                	<input name="prdMdl" id="prdMdl" type="text" class="ui-textbox" readonly>
				                </div>
				            </div>
				            <div class="fieldBox col_33">
				            	<div class="label">建议价格(元)</div>
				                <div class="field">
				                	<input name="guidePcDouble" id="guidePcDouble" type="text" class="ui-textbox" readonly>
				                </div>
				            </div>
				            <div id="dyncBizdiv">
			                	<%-- <jsp:include page="prdTkInfoAddDynamicPage.jsp"></jsp:include> --%>
			                </div>
				            <div class="fieldBox col_33">
				            	<div class="label">子产品建议价格(元)</div>
				                <div class="field">
				                	<input name="guidePcDouble_tkBus" id="guidePcDouble_tkBus" data-tofix="2" type="text" class="ui-textbox" validate ="{number:true}">
				                    <input name="pId" id="pId" type="hidden" value="${id }">
				                </div>
				            </div>
				            <!-- <div class="fieldBox col_100">
				            	<div class="label">备注</div>
				                <div class="field">
				                	<input name="prdRem" id="prdRem" type="text" class="ui-textbox" readonly>
				                </div>
				            </div> -->
                        </div>
            	</td>
            </tr>
		</tbody>
	</table>
			            <%-- <div id="btnsBox" class="btnsBox">
			                <c:if test="${isShowAuditBtn==1 }">
				                <span id="passBtn" class="sq-button sq-button-round" onclick="auditPass(${id});">审核通过</span>
				                <span id="noPassBtn" class="sq-button sq-button-round" onclick="auditNoPass(${id});">审核不通过</span>
			                </c:if>
			            </div> --%>
	</form>
	</div>
</body>

<script type="text/javascript">
var _bizTypCd = '${bizTypCd}';
var _bizCd = '${bizCd}';
var _sGrpCd = '${sGrpCd}';
var _sCode = '${sCode}';
var _prdId = '${prdId}';
var isShowAuditBtn = '${isShowAuditBtn}';

$(function () {
	var form = $("#formSet1").ligerForm({
		validate: true
    });
	var _url = '<%=path%>/product/prdTkInfo/toTkDynamicFldPage.do';
	//刷新动态组件
	frameElement.dialog.disabledBtns();//禁用弹框保存按钮
	var wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
    $("#dyncBizdiv").load(_url,{bizTypCd:_bizTypCd, bizCd:_bizCd},function(responseText,textStatus){
		//dynamicBizPageUIInst();//重新设置字段样式,本方法应该在动态页面中自己根据动态字段写好
		$("#formSet1").check_ligerFormEditor();
		wait_dialog.close();
		frameElement.dialog.enabledBtns();//启用弹框保存按钮
		/*$.ajax({
       		type: 'post',
       		dataType:'json',
       		data:{mTypCd:'M0003', sGrpCd:_sGrpCd, sCode:_sCode},
       		url: '<%=path%>/product/prdBscInfo/searchSysCdMapDWithTargetAtomForSelect.do',
       		success:function(msg){
       			 if(msg.success == 1){
       				//设置驱动值-卡车
       				var drvTyp = $("#drvTyp");
       				if(drvTyp.length){
	       				$("#drvTyp").empty();
       					$("#drvTyp").append("<option value=' '>请选择</option>");
	       				$.each(msg.data,function(index,obj) {
	       					var option = "<option sGrpCd='"+obj.sGrpCd+"' sCode='"+obj.sCode+"' value='"+obj.tCode+"'>"+obj.tCodeNm+"</option>";
	       					$(option).appendTo("#drvTyp");
	       				 	liger.get("drvTyp").setSelect();
	       				});
	       				$("#drvTyp").add_ligerFormEditor();
	       				//liger.get("drvTyp").selectValue(msg.data[0].tCode);
       				}
       				//设置驱动值-卡车类客车  驱动数据同卡车
       				var drvTypCd = $("#drvTypCd");
       				if(drvTypCd.length){
	       				$("#drvTypCd").empty();
       					$("#drvTypCd").append("<option value=' '>请选择</option>");
	       				$.each(msg.data,function(index,obj) {
	       					var option = "<option sGrpCd='"+obj.sGrpCd+"' sCode='"+obj.sCode+"' value='"+obj.tCode+"'>"+obj.tCodeNm+"</option>";
	       					$(option).appendTo("#drvTypCd");
	       				 	liger.get("drvTypCd").setSelect();
	       				});
	       				$("#drvTypCd").add_ligerFormEditor();
	       				//liger.get("drvTyp").selectValue(msg.data[0].tCode);
       				}
       				SetIframe_height();
       			 }else{
       				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
       			 }
       		}
   		});*/
		//请求排序后的马力数据
		$.ajax({
       		type: 'post',
       		dataType:'json',
       		url: '<%=path%>/product/prdBscInfo/getHpData.do',
       		success:function(data){
       			 if(data){
       				$("#hp").empty();
       				$("#hp").append("<option value=' '>请选择</option>");
       				$.each(data,function(index,obj) {
       					var option = "<option value='"+obj.key+"'>"+obj.value+"</option>";
       					$(option).appendTo("#hp");
       				 	liger.get("hp").setSelect();
       				});
       				$("#hp").add_ligerFormEditor();
       				//liger.get("hp").selectValue(data[0].key);
       				SetIframe_height();
       			 }
       		}
   		});
		initData();//加载完组件后初始化数据
    });
	setPrdBscInfo();
});

//审核通过
function auditPass(_prdDtlId){
	if(StringUtils.isEmpty(_prdDtlId)) return;
	var url = '<%=path%>/product/prdTkBusInfo/modifyAudStsCd.do';
    var wait_dialog;
    $.ajax({
		type: 'post',
		dataType:'json',
		data:{id:_prdDtlId,audStsCd:FlowConstant.FLOW_CHECK_STATE_PASS},
		url: url,
		beforeSend: function(){
	          wait_dialog=top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
	     },
		success:function(msg){
			 wait_dialog.close();
			 if(msg.success == 1){
				 top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
				 parent.callback();//刷新列表
		         //frameElement.dialog.close();//关闭弹出框
			 }else{
				 top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
			 }
		}
	});
}
//审核不通过
function auditNoPass(_prdDtlId){
	if(StringUtils.isEmpty(_prdDtlId)) return;
	var url = '<%=path%>/product/prdTkBusInfo/modifyAudStsCd.do';
    var wait_dialog;
    $.ajax({
		type: 'post',
		dataType:'json',
		data:{id:_prdDtlId,audStsCd:FlowConstant.FLOW_CHECK_STATE_NO_PASS},
		url: url,
		beforeSend: function(){
	          wait_dialog=top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
	     },
		success:function(msg){
			 wait_dialog.close();
			 if(msg.success == 1){
				 top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
				 parent.callback();//刷新列表
		         //frameElement.dialog.close();//关闭弹出框
			 }else{
				 top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
			 }
		}
	});
}

//定义父级调用事件
frameElement.dialog.onOk = function () {
	 frameElement.dialog.disabledBtns();//禁用弹框保存按钮
     save();
}
frameElement.dialog.onCancel = function () {
     frameElement.dialog.close();
}
frameElement.dialog.audPass = function () {
	 var id = $("#pId").val();
	 auditPass(id);
}
frameElement.dialog.audNoPass = function () {
	 var id = $("#pId").val();
	 auditNoPass(id);
}
function save(){
	var form = liger.get("formSet1");
    if (!form.valid()) {
    	$.ligerDialog.SQalert({content:LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
        return false; //验证不通过，不执行以下代码
    }
    var data = form.getData();
	data["prdId"] = _prdId;//产品ID
	var id = $("#pId").val();
   	var url='<%=path%>/product/prdTkBusInfo/add.do';
   	if(id != ""){
    	url = '<%=path%>/product/prdTkBusInfo/modify.do';
    	data["id"]= id;
    }
   	var wait_dialog;
    $.ajax({
		type: 'post',
		dataType:'json',
		data:data,
		url: url,
		beforeSend: function(){
	          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
	    },
		success:function(msg){
			wait_dialog.close();
			 frameElement.dialog.enabledBtns();//启用弹框保存按钮
			 if(msg.success == 1){
				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
	             parent.callback_tkBus();//刷新列表
	             if(isShowAuditBtn!='1'){
			         frameElement.dialog.close();//关闭弹出框
	             }
			 }else{
				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
			 }
		}
	});
}
	function setPrdBscInfo(){
		if(!_prdId){
			return;
		}
    	var _url = '<%=path%>/product/prdBscInfo/getById.do';
    	$.ajax({
    		type: 'get',
    		dataType:'json',
    		data:{id:_prdId},
    		url: _url,
    		success:function(msg){
    			 if(msg.success == 1){
    				 setPrdBscInfoData(msg.data);//设置数据
    			 }else{
    				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
    			 }
    		}
    	});
   	}
	//设置产品基本信息	
	function setPrdBscInfoData(data){
		var form = liger.get("formSet1");
		form.setData({
			prdNm:data.prdNm,
			prdTypCdNm:data.prdTypCdNm,
			mfrNm:data.mfrNm,
			brCdNm:data.brCdNm,
			isValidNm:data.isValidNm,
			prdMdl:data.prdMdl,
			guidePcDouble:data.guidePcDouble,
			//prdRem:data.prdRem,
    	});
	}
	function initData(){
			var id = $("#pId").val();
			if(!id){
				return;
			}
	    	var _url = '<%=path%>/product/prdTkBusInfo/getById.do';
	    	$.ajax({
	    		type: 'get',
	    		dataType:'json',
	    		data:{id:id},
	    		url: _url,
	    		success:function(msg){
	    			 if(msg.success == 1){
	    				 setData(msg.data);//设置数据
	    			 }else{
	    				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
	    			 }
	    		}
	    	});
    	}
	function setData(data){
		var form = liger.get("formSet1");
		form.setData({
			carLen:data.carLen,
			prdYr:data.prdYr,
			prdCyCd:data.prdCyCd,
			outVol:data.outVol,
			grboxTypCd:data.grboxTypCd,
			grboxCfg:data.grboxCfg,
			seatQtyCd:data.seatQtyCd,
			engMdl:data.engMdl,
			drvTypCd:data.drvTypCd,
			carStrcCd:data.carStrcCd,
			carStrcCfg:data.carStrcCfg,
			powerTypCd:data.powerTypCd,
			carCl:data.carCl,
			maxSpd:data.maxSpd,
			prdWayCd:data.prdWayCd,
			carMdl:data.carMdl,
			othCfg:data.othCfg,
			guidePcDouble_tkBus:data.guidePcDouble_tkBus
		});
	}
	
</script>